While Loops (Crystal syntax)

Another looping mechanism is the While loop. A While loop can be used to execute a fixed block of statement an indefinite amount of time.

The 2 different types of While loops
Type of Do Loop Explanation Example

While ... Do

The While ... Do loop evaluates the condition, and if the condition is true, then it evaluates the expression following the Do.


When it has finished doing this, it evaluates the condition again and if the condition is true, it evaluates the expression following the Do again. It continues repeating this process until the condition is false.

While condition Do
   expression

Do ... While

The Do ... While loop evaluates the expression once no matter what.


It then evaluates the condition, and if the condition is true, evaluates the expression again. This process continues until the condition is false.

Do
   expression
While condition

Note:    



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com